package org.glut.backend.controller;


import lombok.extern.slf4j.Slf4j;
import org.glut.backend.domain.Functionbar;
import org.glut.backend.service.IFunctionbarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能栏表 前端控制器
 *
 * @author hjd
 * @since 2025-08-02 23:38
 */
@Slf4j
@RestController
@RequestMapping("/public/maoyanmovieproject")
public class FunctionbarController {

    @Autowired
    IFunctionbarService functionbarService;
    /**
     * 根据id查询功能栏图片
     * @param id
     * @return
     */
    @GetMapping("/queryFunctionBarById/{id}")
    public ResponseEntity<Functionbar> getById(@PathVariable Integer id) {
        log.info("ID:{}",id);
        Functionbar functionbar = this.functionbarService.getById(id);
        //定义http请求头
        HttpHeaders httpHeaders = new HttpHeaders();
        //添加自定义请求头
        httpHeaders.add("token", "haha");
        return new ResponseEntity<Functionbar>(functionbar, httpHeaders, HttpStatus.OK);
    }

    /**
     * 查询所有功能栏
     *
     * @return
     */
    // FunctionbarController.java
    @GetMapping("/queryAllFunctionBar")
    public ResponseEntity<List<Functionbar>> queryAllFunctionBar() {
        List<Functionbar> list = functionbarService.list(); // 查询所有功能栏
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add("token", "haha");
        return new ResponseEntity<>(list, httpHeaders, HttpStatus.OK);
    }


}
